import java.util.Arrays;
import java.util.Comparator;

/**
 * @ClassName Demo05
 * @Description TODO
 * @Author Li
 * @Date 2022/8/14 15:06
 * @ModifyDate 2022/8/14 15:06
 * @Version 1.0
 */
public class Demo05 {
    private static Comparator<String> compare() {
        return (a, b) -> b.length() - a.length();
    }

    public static void main(String[] args) {
        String[] arr = {"abc", "ab", "abcd"};
        System.out.println(Arrays.toString(arr));
        Arrays.sort(arr, compare());
        System.out.println(Arrays.toString(arr));
    }
}
